<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>css的日夜</title>
  <style>
    body {
      margin: 0;
      padding: 0;
    }

    .sun {
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: #ffeea2;

      display: flex;

      justify-content: center;
      align-items: center;
      z-index: 10;

      clip-path: inset(0px 50% 0px 0px);
    }

    .sun::after {
      content: '';
      display: block;
      width: 600px;
      height: 600px;
      background-color: orange;
      border-radius: 50%;
    }

    .moon {
      position: absolute;
      background-color: #040720;
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .moon::after {
      content: '';
      display: block;
      width: 600px;
      height: 600px;

      border-radius: 50%;
      /* 弯月是使用阴影来实现的，也可以使用div覆盖的方式 */
      box-shadow: 160px 180px 0px cyan;
      transform: translate(-160px, -180px);

    }

    .sea {
      position: absolute;
      bottom: 0;
      width: 100%;
      height: 30%;
      backdrop-filter: blur(100px);
      -webkit-backdrop-filter: blur(100px);
      z-index: 20;

    }
  </style>
</head>

<body>
  <div class="sun"></div>
  <div class="moon"></div>

  <div class="sea"></div>

  <script>
    window.addEventListener('mousemove', (e) => {
      let percentage = (100 - e.clientX / window.innerWidth * 100)
      console.log(100 - e.clientX / window.innerWidth * 100)
      document.querySelector('.sun').style.clipPath = `inset(0px ${percentage}% 0px 0px)`
    })
  </script>
</body>

</html>